package com.tianbing.adlottery.controller;

import java.beans.PropertyEditor;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.mvc.SimpleFormController;

public class AdLotterySimpleFormController extends SimpleFormController {
	static Logger logger = Logger.getLogger(AdLotterySimpleFormController.class.getName());

	private PropertyEditor customDateEditor;

	@Override
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
		binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true));
		super.initBinder(request, binder);
	}

	public void setCustomDateEditor(PropertyEditor customDateEditor) {
		this.customDateEditor = customDateEditor;
	}

}
